package la.bbs558.controller.user;

import cn.dev33.satoken.stp.StpUtil;
import la.bbs558.aop.valid.Check;
import la.bbs558.controller.base.BaseController;
import la.bbs558.controller.base.Result;
import la.bbs558.entity.enums.UserMessageType;
import la.bbs558.entity.params.UserMessagePage;
import la.bbs558.service.UserMessageService;
import la.bbs558.service.UserPushService;
import la.bbs558.util.EnumUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Classname UserController
 * @Description 用户配置
 * @Date 2023/12/15 10:27
 * @Created by weihanmin
 */
@RestController
@RequestMapping("user/message")
@Check
public class UserMessageController extends BaseController {

    @Resource
    private UserMessageService userMessageService;

    @Resource
    private UserPushService userPushService;

    @GetMapping("user")
    public Result<?> userMessage(@Validated UserMessagePage page) {
        userMessageService.userMessage(page);
        return Result.success(page);
    }

    @GetMapping("count")
    public Result<?> messageCount() {
        Integer res = userMessageService.messageCount();
        return Result.success(res);
    }

    @GetMapping("statistics")
    public Result<?> messageStatistics() {
        return Result.success(userMessageService.messageStatistics(StpUtil.getLoginIdAsLong()));
    }

    @GetMapping("messageEnum")
    public Result<?> messageEnum() {
        return Result.success(EnumUtils.toList(UserMessageType.class,"desc","code"));
    }

}
